home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / PPCExamples / AExamples / AsmSample / AsmSample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-03  |  1.3 KB  |  50 lines  |  [TEXT/MPS ]

  1. #include <Windows.h>    // for GetNewWindow()
  2. #include <Fonts.h>        // for InitFonts()
  3. #include <Dialogs.h>    // for InitDialogs, paramtext & Alert
  4. #include <Quickdraw.h>    // for InitGraf
  5.  
  6. /* defines */
  7. #define kChooseAMessageAlertID 128
  8. #define kDisplayMessageAlertID 129
  9.  
  10. /* globals */
  11. const char *gHelloString = "Hello, World!";
  12. const char *gGoodbyeString = "Goodbye, Cruel World!";
  13. struct QDGlobals qd;
  14.  
  15. void main()
  16. {
  17.     short itemHit;        // for the "Choose a Message" Alert
  18.     
  19.     /* Initialize program and put up an alert */
  20.     /* Note the horrible user interface here.  No menus, no
  21.     "real" event loop, etc. */
  22.     InitGraf((Ptr) &qd.thePort);
  23.     InitFonts();
  24.     InitWindows();
  25.     InitMenus();
  26.     TEInit();
  27.     InitDialogs(nil);
  28.     InitCursor();
  29.  
  30.     /* Wait for the user to choose… */
  31.     itemHit = Alert(kChooseAMessageAlertID, nil);
  32.     
  33.     /* Call the assembly language routine to handle the user's choice.
  34.         This is an example of an assembly language routine
  35.         being called from (and passing data to) a C routine.  */
  36.     ClickHandler(itemHit);
  37.     
  38. }
  39.  
  40. void DisplayAlert(char *message) {
  41. /* this routine doesn't care which message the Asm routine
  42.    passes it.  It just displays it in an alert. 
  43.    This is an example of a C routine being called from an
  44.    assembly language routine.*/
  45.     short itemHit;
  46.     
  47.     paramtext(message, "", "", "");
  48.     itemHit = Alert(kDisplayMessageAlertID, nil);
  49. }
  50.